﻿using Microsoft.SmallBasic.Library;

namespace SmallBasicFun
{
	/// <summary>
	/// The color wheel allows you to 
	/// set up up a color palette with multiple colors that you can use.
	/// </summary>
	[SmallBasicType]
	public static class ColorWheel
	{
		private static Wheel<Primitive> wheel = new ExitIfEmptyWheel();
		public static Wheel<Primitive> GetWheel()
		{
			return wheel;
		}
		public static void SetWheel(Wheel<Primitive> value)
		{
			wheel = value ;
		}


		/// <summary>
		/// Adds a color to the available colors on the Color Wheel
		/// </summary>
		/// <example> ColorWheel.AddColor("purple")</example>
		/// <param name="color">
		/// the color to add
		/// </param>
		
		public static void AddColor(Primitive color)
		{
			wheel.Add(color);
		}

		/// <summary>
		/// Shows the next color on the Color Wheel
		/// </summary>
		/// <example>Tortise.SetPenColor(ColorWheel.GetNextColor())</example>
		/// <returns>
		/// The next color
		/// </returns>
		public static Primitive GetNextColor()
		{	
			return wheel.GetNext();
		}
		/// <summary>
		/// Selects a random color from the colors on the Color Wheel.
		/// Useful for when you don't want your colors in any particular order.
		/// </summary>
		/// <example>Tortise.SetPenColor(ColorWheel.GetRandomColor())</example>
		/// <returns>
		/// One of the colors you've added
		/// </returns>
		public static Primitive GetRandomColor()
		{
			
			return wheel.GetRandom();
		}

		/// <summary>
		/// Removes all colors from the Color Wheel. Allowing you to start over.
		/// </summary>
		/// <example>ColorWheel.RemoveAllColors()</example>
		
		public static void RemoveAllColors()
		{
			wheel.RemoveAll();
		}
		
	}

	internal class ExitIfEmptyWheel : Wheel<Primitive>
	{
		public override Primitive ReturnIfEmpty()
		{
			MessageBox.ShowMessage("There are no colors on the Color Wheel");
			Program.End();
			return Colors.Black;
		}
	}
}